﻿using MediatR;
using S.EarTag.API.Mediator.MediatorCommand.EarTagCommand;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;
using Serilog;

namespace S.EarTag.API.Mediator.MediatorCommandHandler.EarTagCommandHandler
{
    public class EarTagUpdDateCommandHandler : IRequestHandler<EarTagUpdDateCommand, bool>
    {
        private readonly IEarTagModelRepository _earTagModelRepository;
        public EarTagUpdDateCommandHandler(IEarTagModelRepository earTagModelRepository)
        {
            _earTagModelRepository = earTagModelRepository;
        }
        /// <summary>
        /// 根据耳标Id修改状态
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<bool> Handle(EarTagUpdDateCommand request, CancellationToken cancellationToken)
        {
           return await _earTagModelRepository.UpdateEarTag(request.EarTagId);

        }
    }
}
